import { createRouter, createWebHistory } from 'vue-router'
//路由表，路由实例：维护路径和组件的关系
//导入路径
import Layout from '@/views/layout/index.vue';
import LoginPage from '@/views/login/index.vue';
import IndexPage from '@/views/index/index.vue';
import ClazzPage from '@/views/clazz/index.vue';
import StuPage from '@/views/stu/index.vue';
import DeptPage from '@/views/dept/index.vue';
import EmpPage from '@/views/emp/index.vue';
import EmpReportPage from '@/views/report/emp/index.vue';
import StuReportPage from '@/views/report/stu/index.vue';
import LogPage from '@/views/log/index.vue';

const router = createRouter({//createRouter是创建路由实例的，创建项目会自带这个类的框架
  history: createWebHistory(import.meta.env.BASE_URL),
  //路由表，用到了路由嵌套
  routes: [
    {
      path: '/',//根路径都是/开头的
      component: Layout,//访问的组件名称，会去找'@/views/layout/index.vue'组件
      redirect: '/index',//重定向，保证在进入界面http://localhost:5174时有默认的首页界面展示
      //子路由
      children: [
        { path: 'index', component: IndexPage },
        { path: 'clazz', component: ClazzPage },
        { path: 'stu', component: StuPage },
        { path: 'dept', component: DeptPage },
        { path: 'emp', component: EmpPage },
        { path: 'empReport', component: EmpReportPage },
        { path: 'stuReport', component: StuReportPage },
        { path: 'log', component: LogPage },
      ],
    },
    //登录界面需要单独定义，登录不需要嵌套
    {
      path: '/login',
      name: 'Login',
      component: LoginPage
    }
  ]
})

export default router

